import { defineStore } from 'pinia';


export const useItemStore = defineStore('item', {
  state: () => ({
    itemIdUrl: '',
    actorIdUrl: '',
    videoDetail: null,
  }),
  actions: {
    setItemIdUrl(itemIdUrl: string) {
      this.itemIdUrl = itemIdUrl;
    },
    setActorIdUrl(actorIdUrl: string) {
      this.actorIdUrl = actorIdUrl;
    },
    async fetchVideoDetail() {
      try {
        const response = await getVideoDetail(this.itemIdUrl, this.actorIdUrl);
        this.videoDetail = response.data;
      } catch (error) {
        console.error('请求视频详情失败:', error);
      }
    },
  },
  persist: true,  // 启用持久化
});
